package cn.edu.scujcc;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/comment")
public class CommentController {
	@Autowired
	private CommentService commentservice;
	
	@GetMapping("/hot")
	public List<Comment> getHotComments(){
		List<Comment> result = null;
		result = commentservice.getHotComments();
		return result;	
	}
	
	@PutMapping("/support/{id}")
	public Comment supportComment(@PathVariable String id) {
		Comment result= null;
		result = commentservice.supportComment(id);
		return result;
	}
	
	private CommentService service;
	@GetMapping("/hot")
	public List<Comment> getHotComment(){
		List<Comment> result = null;
		result = service.getHotComments();
		return result;
	}
	@GetMapping
	public List<Comment> getAllComment(){
		List<Comment> result = null;
		result = service.getAllComments();
		return result;
	}
	@PostMapping
	public Comment newComment(@RequestBody Comment c) {
		Comment result = null;
		result = service.newComment(c);
		return result;
	}
	@PutMapping("/up/{id}")
	public Comment getComment(@PathVariable String id) {
		Comment result= null;
		result = service.upComment(id);
		return result;
	}
	@DeleteMapping("/{id}")
	public boolean deleteChannel(@PathVariable String id) {
		boolean result= false;
		result = service.deleteComment(id);
		return result;
	}
}
